#!/usr/bin/env bash

# the script will exit if there is any error
set -e

if [ -z "$WM_PROJECT" ]; then
  echo "OpenFOAM environment not found, forgot to source the OpenFOAM bashrc?"
  exit 1
fi

if [ -z "$1" ]; then
  echo "Argument not found. Using the default value: opt"
  argm="opt"
else
  argm="$1"
fi

cd src/adjoint && ./Allmake $argm && cd -
cd src/pyDASolvers && ./Allmake $argm && cd -
cd src/utilities/coloring && ./Allmake $argm && cd -
cd src/utilities/postProcessing && ./Allmake $argm && cd -